<?php namespace App\Client\Apply\Exchange\Criterias;

use Auth;
use App\Core\Repository\Criteria;
use App\Core\Repository\Repository;

class MatchClient extends Criteria{

    public function apply(Repository $repository){
        parent::apply($repository);
        $user = Auth::user();
        $client = $user->client;
        if(!$client){
            $this->query->whereRaw('1=0');
            return ;
        }
        $this->query->where($this->formatField($this->model, 'client_id'), '=', $client->id);
    }
}